/*
 * Copyright 2016-2017 TVI Go Easy.
 * Created on 2017/4/19 11:30
 */
package org.mechanic.fund.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger 2 配置
 *
 * @author mechanic
 * @version 0.0.1
 */
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
    @Bean
    public Docket createRestApi()
    {
        return new Docket(DocumentationType.SWAGGER_2)
          .apiInfo(apiInfo())
          .select()
          .apis(RequestHandlerSelectors.basePackage("org.mechanic.fund.web"))
          .paths(PathSelectors.any())
          .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
          .title("Swagger2")
          .description("Swagger")
          .termsOfServiceUrl("http://www.g-easy.com.cn")
          .contact(contact())
          .version("1.0")
          .build();
    }

    private Contact contact()
    {
        return new Contact("Mechanic",
                           "http://www.g-easy.com.cn",
                           "feng.cheng@techviewinfo.com");
    }
}
